package PTA_Test;

import com.sun.scenario.effect.impl.sw.java.JSWInvertMaskPeer;

abstract class Animal{   //动物类
    private String name;//名字
    private String color;//颜色
    private String type;//类别（哺乳类、非哺乳类）
    public Animal(String name, String color, String type){
        this.name = name;
        this.color = color;
        this.type = type;
    }
    public String getName(){
        return name;
    }
    public String getColor(){
        return color;
    }
    public String getType(){
        return type;
    }
    public abstract void shout();
    public abstract void eat();
}
/* 请在这里填写答案 */
interface Swimmable {
    abstract void swim();
}

interface Flyable {
    abstract void fly();
}
class Rabbit extends Animal {
    public Rabbit(String name, String color, String type) {
        super(name, color, type);
    }
    @Override
    public void shout() {
        System.out.println("那只"+super.getColor()+"的，名字叫"+super.getName()
            +"的兔子正在叽叽的叫");
    }
    @Override
    public void eat() {
        System.out.println("兔子是哺乳类,爱吃胡萝卜");
    }
}

class Frog extends Animal implements Swimmable {
    public Frog(String name, String color, String type) {
        super(name, color, type);
    }
    @Override
    public void shout() {
        System.out.println("那只"+super.getColor()+"的，名字叫"+super.getName()
                +"的青蛙正在呱呱的叫");
    }
    @Override
    public void eat() {
        System.out.println("青蛙是非哺乳类,爱吃昆虫");
    }

    @Override
    public void swim() {
        System.out.println("青蛙是游泳高手");
    }
}
class Eagle extends Animal implements Flyable {
    public Eagle(String name, String color, String type) {
        super(name, color, type);
    }
    @Override
    public void shout() {
        System.out.println("那只"+super.getColor()+"的，名字叫"+super.getName()
                +"的老鹰正在啾啾的叫");
    }
    @Override
    public void eat() {
        System.out.println("老鹰是非哺乳类,爱吃小鸡");
    }

    @Override
    public void fly() {
        System.out.println("老鹰是飞翔高手");
    }
}

public class pta_6_48{
    public static void main(String[] args) {
        AnimalAction(new Rabbit("小白", "白色", "哺乳类"));
        System.out.println("====================");
        AnimalAction(new Frog("弗洛格", "绿色", "非哺乳类"));
        SwimAction(new Frog("弗洛格", "绿色", "非哺乳类"));
        System.out.println("====================");
        AnimalAction(new Eagle("凤头鹰","灰色","非哺乳类"));
        FlyAction(new Eagle("凤头鹰","灰色","非哺乳类"));
    }
    public static void AnimalAction(Animal an) {
        an.shout();
        an.eat();
    }
    public static void SwimAction(Swimmable s) {
        s.swim();
    }
    public static void FlyAction(Flyable f) {
        f.fly();
    }
}